﻿CREATE PROCEDURE [dbo].[spMOMPortAll]
	@OwnerID int
AS
begin try
	declare @message nvarchar(1000)
	if ( select 1 from tblOwner where OwnerID = @OwnerID ) is null
		return
	begin transaction
	exec spMOMPortInitial @OwnerID
	exec spMOMPortSubscriptions @OwnerID
	exec spMOMPortCustomers @OwnerID
	exec spMOMPortOrders @OwnerID
	exec spMOMPortShipping @OwnerID
	exec spMOMPortRMA @OwnerID
	exec spMOMPortJournal @OwnerID
	commit
	set @message = 'Rebuild search keys ' + convert( varchar, getdate(), 9 )
	RAISERROR (@message, 0, 1) WITH NOWAIT
	exec spRebuildAllSearchKeys @OwnerID
end try
begin catch
	rollback
	exec usp_RethrowError
end catch
